<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>全局公告和发帖</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/css/email/writeMail.css"/>
    <script src="/js/common/language.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/email/writeMail.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script type="text/javascript" src="../js/spirit/qwebchannel.js"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <style>
        .files a{text-decoration: none;}
        a{
            text-decoration: none;
            color: #207BD6;
            cursor: pointer;
        }
        #attention{
            margin: 0;
            padding:0;
            list-style: none;
            width:100px;
            position: absolute;
            left: 10px;
            text-align: center;
            display: none;
            z-index: 9999;
            border:#ccc 1px solid;
            top:20px;
        }
        #attention li{
            background: #ffffff;
            cursor:pointer;
            line-height: 22px;
        }
        #attention li:hover{
            background-color: #6ea1d5;
            color: #fff;
        }
        .choose{
            width: 180px;
            position: absolute;
            left: 255px;
            top: 0px;
        }
        .bar {
            height: 18px;
            background: green;
        }
        .box{width:200px; height:20px; }
        .tbox{width:200px; height:20px; background:url(/img/email/bak.png) no-repeat;background-size: 100% 100%;}
        .tbox div{width:0px; height:20px; background:url(/img/email/pro.png) no-repeat;background-size: 100% 100%;text-align:center;font-size:14px; line-height:20px;}
    </style>
</head>
<body>
<table class="TABLE" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;margin-bottom: 20px;margin-top: 30px">

    <%--原贴--%>
    <tr>
        <td width="15%" style="padding-left: 10px;">
            <p>原贴:</p>
            <p class="Color"><a href="javascript:;" onclick="empty()"><fmt:message code="global.lang.empty" /></a></p>
        </td>
        <td width="85%">
            <scrtpt id="container" style="width: 99.9%;min-height: 300px;" name="content" type="text/plain"></scrtpt>
        </td>
    </tr>
    <%--回帖标题--%>
    <tr class="append_tr">
        <td width="15%" style="padding-left: 10px;">回帖标题:</td>
        <td width="85%">
            <input type="text" id="titleName" style="width: 70%;" class="input_txt">
        </td>
    </tr>

    <%--分类 table-row--%>
    <tr class="append_tr" style="display: none">
        <td width="15%" style="padding-left: 10px;">分类:</td>
        <td width="85%">
            <select name="type" style="width: 30%;height: 25px;margin: 5px;">

            </select>
        </td>
    </tr>
    <%--回帖内容--%>
    <tr>
        <td width="15%" style="padding-left: 10px;">
            <p>回帖内容:</p>
            <%--<p class="Color"><a href="javascript:;" onclick="empty()"><fmt:message code="global.lang.empty" /></a></p>--%>
        </td>
        <td width="85%">
            <scrtpt id="container1" style="width: 99.9%;min-height: 300px;" name="content" type="text/plain"></scrtpt>
        </td>
    </tr>
    <%--附件文档--%>
    <tr class="Attachment" style="width:100%; padding-left: 10px; display: none">
        <td width="15%">附件文档:</td>
        <td width="85%"   class="files" id="files_txt">
            <div id="fileContent"></div>
        </td>
    </tr>
    <%--附件选择--%>
    <%--<tr style="display: none">--%>
        <%--<td width="15%" style="padding-left: 10px;">附件选择:</td>--%>
        <%--<td width="85%" class="files" style="position: relative">--%>
            <%--<!-- <fmt:message code="email.th.addfile" /> -->--%>
            <%--<form id="uploadimgform" style="float: left;" target="uploadiframe"  action="/upload?module=email"  method="post" >--%>
                <%--<input type="file" multiple="multiple" name="file"  id="uploadinputimg"  class="w-icon5" style="position: absolute;opacity: 0;width: 70px;filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">--%>
                <%--<a href="#" id="uploadimg"><img style="margin-right:5px;" src="../img/icon_uplod.png"/><fmt:message code="global.th.fileup" /></a>--%>
            <%--</form>--%>
            <%--&lt;%&ndash;<a href="javascript:;" onclick="formFile()" style="float: left;margin: 0 15px;"><img style="margin-right:5px;" src="../img/icon_uplod.png"/>从文件柜选择附件</a>&ndash;%&gt;--%>
            <%--<div id="progress" style="width: 200px;float: left;margin-left: 10px;margin-top: 2px;">--%>
                <%--<div class="bar" style="width: 0%;"></div>--%>
            <%--</div>--%>
            <%--<div class="barText" style="float: left;margin-left: 10px;"></div>--%>
        <%--</td>--%>
    <%--</tr>--%>
    <%--署名--%>
    <tr>
        <td width="15%" style="padding-left: 10px;">署名:</td>
        <td width="85%" class="remind">
            <div class="news_t">
                <input type="radio" name="nameRemind" class="remindCheck" value="1" checked >
                <input id="authorName" type="text" class="input_txt" value="${userName}" disabled >

                <%----%>
                <span name="nickname">
                    <input  type="radio" name="nameRemind" class="remindCheck" value="2">
                    昵称
                    <input  id="nickName" type="text"  class="input_txt" value="${userName}">
                </span>

            </div>

        </td>
    </tr>

    <%--事务提醒讨论区人员--%>
    <tr>
        <td width="15%" style="padding-left: 10px;">事务提醒讨论区人员:</td>
        <td width="85%" class="remind">
            <div class="news_t">
                <input type="radio" name="thingRemind" class="thingRemind" value="0" checked >手动选择被提醒人员
                <span>&nbsp;</span>
                <input type="radio" name="thingRemind" class="thingRemind" value="1"  >提醒全部有权限
                <div name="senduser">
                    <textarea name="txt" id="senduser" user_id='' style="min-width: 70%;" value="" disabled></textarea>
                    <span class="add_img" style="margin-left: 10px">
							<a href="javascript:;" id="selectUser" class="Add "><fmt:message code="global.lang.add" /></a>
						</span>
                    <span class="add_img">
							<a href="javascript:;" class="clear"><fmt:message code="notice.th.delete1" /></a>
						</span>
                </div>
            </div>

        </td>
    </tr>
</table>

<script type="text/javascript">
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var boardId=getQueryString("boardId");
    var commentId=getQueryString("commentId");

    var uid = $.GetRequest().uid|| '';
    var uname = $.GetRequest().uname|| '';
    var attach_id='';
    window.console = window.console || (function(){
            var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function(){};
            return c;
        })();

    //当浏览器窗口改变时，根据浏览器窗口大小重新定义表格宽高
    $(window).resize(function() {
        $('.TABLE').width($(document).width()-100);
        $('.TABLE').height($(document).height()-100);
    });

    //			附件上传方法
    fileuploadFn('#uploadinputimg',$('.Attachment td').eq(1));

    //			从文件柜上传文件
    function formFile() {
        attach_id='fileContent';
        //$.popWindow("/email/formFileCabinet");
    }

    //事务提醒单选框监听事件
    $("input[name='thingRemind']").click(function(){
        var val=$('input:radio[name="thingRemind"]:checked').val();
        if(val===0 || val==='0'){
            $('div[name="senduser"]').css("display","block");
        }else{
            $('#senduser').attr('user_id','');
            $('#senduser').attr('username','');
            $('#senduser').val('');
            $('div[name="senduser"]').css("display","none");
        }
    });

    //选人控件
    $("#selectUser").on("click",function(){
        user_id='senduser';
        $.popWindow("../common/selectUser");
    });

    $(document).delegate('.clearBCC', 'click', function () {
        $('#secritText').attr('username', '');
        $('#secritText').attr('dataid', '');
        $('#secritText').attr('user_id', '');
        $('#secritText').attr('userprivname', '');
        $('#secritText').val('');
    })
    $(document).delegate('.clearCC', 'click', function () {
        $('#copeNameText').attr('username', '');
        $('#copeNameText').attr('dataid', '');
        $('#copeNameText').attr('user_id', '');
        $('#copeNameText').attr('userprivname', '');
        $('#copeNameText').val('');
    })

    //附件删除
    $('#files_txt').on('click', '.deImgs', function () {
        var data = $(this).parents('.dech').attr('deUrl');
        var dome = $(this).parents('.dech');
        deleteChatment(data, dome);
    });

    //清空UE内容
    function empty(){
        ue.setContent('');
    }

    //点击立即发送按钮
    function save() {
        var titleName=$('#titleName').val();
        var authorNameTmep=$('input[name="nameRemind"]:checked').val();/*1-署名,2-昵称*/
        var authorName=$('#authorName').val();
        var nickName=$('#nickName').val();
        var userId=$('textarea[name="txt"]').attr('user_id');
        var type=$('select[name="type"]').val();

        var txt = ue.getContentTxt();
        var html = ue1.getContent();
        var attach = $('.Attachment td').eq(1).find('a');
        var aId = '';
        var uId = '';
        for (var i = 0; i < $('.Attachment td .inHidden').length; i++) {
            aId += $('.Attachment td .inHidden').eq(i).val();
        }
        for (var i = 0; i < $('.Attachment td .inHidden').length; i++) {
            uId += attach.eq(i).attr('NAME');
        }

        var data = {
            boardId: boardId,
            subject:titleName,
            authorName: authorName,
            type:type,
            content: html,//x回帖内容
            attachmentId: aId,
            attachmentName: uId,
            authorNameTmep:authorNameTmep,
            nickName:nickName,
            toIdStr1:userId,
            toIdStr2:userId,
            parent:commentId,
        };

//        if ($('.barText').html() != '' && $('.barText').html() != "100%") {
//            layer.msg('附件还未上传完毕！', {icon: 2});
//            return false;
//        }
        layer.load(0, {shade: [0.2, '#ffffff']});
        $.ajax({
            type: 'post',
            url: '/bbs/addCom',
            dataType: 'json',
            data: data,
            success: function (rsp) {
                var flag=rsp.flag;
                window.parent.layertrue(flag);
            }
        });
    }
    //编辑保存按钮
   /* //点击立即发送按钮
    function editOver() {
        var titleName=$('#titleName').val();
        var authorNameTmep=$('input[name="nameRemind"]:checked').val();/!*1-署名,2-昵称*!/
        var authorName=$('#authorName').val();
        var nickName=$('#nickName').val();
        var userId=$('textarea[name="txt"]').attr('user_id');
        var type=$('select[name="type"]').val();

        var txt = ue.getContentTxt();
        var html = ue.getContent();
        var attach = $('.Attachment td').eq(1).find('a');
        var aId = '';
        var uId = '';
        for (var i = 0; i < $('.Attachment td .inHidden').length; i++) {
            aId += $('.Attachment td .inHidden').eq(i).val();
        }
        for (var i = 0; i < $('.Attachment td .inHidden').length; i++) {
            uId += attach.eq(i).attr('NAME');
        }

        var data = {
            commentId:commentId,
            boardId: boardId,
            subject:titleName,
            authorName: authorName,
            type:type,
            content: html,
            attachmentId: aId,
            attachmentName: uId,
            authorNameTmep:authorNameTmep,
            nickName:nickName,
            toIdStr1:userId,
            toIdStr2:userId,
        };

        if ($('.barText').html() != '' && $('.barText').html() != "100%") {
            layer.msg('附件还未上传完毕！', {icon: 2});
            return false;
        }
        layer.load(0, {shade: [0.2, '#ffffff']});
        $.ajax({
            type: 'post',
            url: '/bbs/updateCom',
            dataType: 'json',
            data: data,
            success: function (rsp) {
                var flag=rsp.flag;
                // window.parent.layertrue(flag);
            }
        });
    }*/

    var user_id='senduser';
    var ue = UE.getEditor('container',{elementPathEnabled : false});
    var ue1 = UE.getEditor('container1',{elementPathEnabled : false});
    UEimgfuc();

    var res;
    $(function() {
        ue.ready(function () {
            ue.setDisabled();
            var flow_view_str = $.getQueryString("flow_view_str") || '';
            if (flow_view_str != '') {
                var str1 = '<link rel="stylesheet" type="text/css" href="/css/workflow/m_reset.css">' +
                    '<link rel="stylesheet" type="text/css" href="../../css/workflow/work/new_work.css">' +
                    '<link rel="stylesheet" type="text/css" href="../../css/workflow/work/bootstrap.css">' +
                    '<link rel="stylesheet" type="text/css" href="../../lib/laydate.css"/>' +
                    '<link rel="stylesheet" type="text/css" href="../../css/workflow/work/handle.css"/>' +
                    '<link rel="stylesheet" type="text/css" href="/css/dept/roleAuthorization.css"/>' +
                    '<link rel="stylesheet" href="/css/workflow/work/workFormPreView.css?20191210.1"><style>.cont_form{height: auto;}</style><br><br>';
                var str = '';
                if (flow_view_str.indexOf('1') > -1) {
                    str += window.top.opener.document.getElementById("a2").outerHTML;
                }
                if (flow_view_str.indexOf('2') > -1) {
                    str += window.top.opener.document.getElementById("files").outerHTML;
                }
                if (flow_view_str.indexOf('3') > -1) {
                    str += window.top.opener.document.getElementById("Opinion").outerHTML;
                }
                if (flow_view_str.indexOf('4') > -1) {
                    str += window.top.opener.document.getElementById("process").outerHTML;
                }
                ue.setContent(str1 + '<div class="content" style="margin-top:0px;"><div class="cont" style="background: #fff" id="client">' + str + '</div></div><script src="/js/workflow/work/workform.js?20200114.1">\<\/script>', true);
            }
        });
    });

    $(function(){
        $('table').width($(document).width()-100);
        var userId=$.getQueryString('userId');
        var userName=$.getQueryString('userName');
        if(userId != null || userName!= null){  //判断userId或者userName是否为空
            $('#senduser').attr('user_id',userId+',');
            $('#senduser').attr('username',decodeURI(userName)+',');
            $('#senduser').val(decodeURI(userName)+',');
        }else{
            $('#senduser').attr('user_id','');
            $('#senduser').attr('username','');
            $('#senduser').val('');
        }

        if(boardId != -1 || boardId !='-1'){
            //分类
            $.get('/system/bbs/getDetail',{boardId:boardId},function(res){
                if (res.flag){
                    var category=res.object.category.split(',')
                    var str=''
                    for(var i=0;i<category.length;i++){
                        str+='<option value="'+category[i]+'">'+category[i]+'</option>'
                    }
                    $('select[name="type"]').html(str)
                    $('.append_tr').eq(1).css("display","table-row");

                    //隐藏署名
                    $('span[name="nickname"]').css("display","none");

                    //显示事务提醒tr
                    $('tr').eq(7).css("display","table-row");
                    //回显
                    $.get('/bbs/selectById',{id:commentId},function(res){
                        if (res.flag){
                            var datas=res.object.Thislevel;
                            $('#titleName').val(datas.subject)
                            $('select[name="type"]').val(datas.type)
                            // ue.setContent(datas.content)
                            ue.ready(function () {
                                ue.setContent('<b>标题:'+datas.subject+'</b><br/>内容:'+datas.content, true);
                            });
                            //附件
                            var arrAttach2 = datas.attachmentList2;
                            var stra2 = '';
                            if (arrAttach2 && arrAttach2.length > 0){
                                for(var i=0;i<arrAttach2.length;i++){
                                    stra2+= '<div class="dech" style="max-width: 550px;" deUrl="' + encodeURI(arrAttach2[i].attUrl)+ '"><a title="'+ arrAttach2[i].attachName +'" style="display:inline-block;width:100%;overflow: hidden; word-break:break-all;white-space: nowrap;text-overflow: ellipsis;" href="<%=basePath %>download?'+encodeURI(arrAttach2[i].attUrl)+'" NAME="' + arrAttach2[i].attachName + '*"><img style="margin-right:10px;" src="../img/attachment_icon.png"/>' + arrAttach2[i].attachName + '</a></div>';
                                }
                            } else {
                                stra2='无附件';
                            }
                            $('#fileContent').html(stra2)
                        }
                    });
                }
            });
        }

    });

</script>
</body>
</html>


